<?php

/**
 * Event filter form base class.
 *
 * @package    Nika
 * @subpackage filter
 * @author     Alexey Shapran (alexey.shapran@gmail.com)
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseEventFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'alias'               => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'title'               => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'branch_id'           => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Branch'), 'add_empty' => true)),
      'short'               => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'body'                => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'keywords'            => new sfWidgetFormFilterInput(),
      'description'         => new sfWidgetFormFilterInput(),
      'image'               => new sfWidgetFormFilterInput(),
      'is_allowed_comments' => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'updated_at'          => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'album_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Album'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'alias'               => new sfValidatorPass(array('required' => false)),
      'title'               => new sfValidatorPass(array('required' => false)),
      'branch_id'           => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Branch'), 'column' => 'id')),
      'short'               => new sfValidatorPass(array('required' => false)),
      'body'                => new sfValidatorPass(array('required' => false)),
      'keywords'            => new sfValidatorPass(array('required' => false)),
      'description'         => new sfValidatorPass(array('required' => false)),
      'image'               => new sfValidatorPass(array('required' => false)),
      'is_allowed_comments' => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'updated_at'          => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'album_id'            => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Album'), 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('event_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Event';
  }

  public function getFields()
  {
    return array(
      'id'                  => 'Number',
      'alias'               => 'Text',
      'title'               => 'Text',
      'branch_id'           => 'ForeignKey',
      'short'               => 'Text',
      'body'                => 'Text',
      'keywords'            => 'Text',
      'description'         => 'Text',
      'image'               => 'Text',
      'is_allowed_comments' => 'Boolean',
      'updated_at'          => 'Date',
      'album_id'            => 'ForeignKey',
    );
  }
}
